﻿using FluentNHibernate.Mapping;
using MvcApplicationDataHound.TSD_Mappings;

namespace MvcApplicationDataHound.Mappings
{
    public class TSD_CarMapping
    {
    }

    public class CarMap : ClassMap<Car>
    {
        public CarMap()
        {
            Id(x=>x.Id);
            Map(x => x.Title);
            Map(x => x.Description);
            References(x => x.Make).Column("MakeId");
            References(x => x.Model).Column("ModelId");
            Table("Car");
        }
    }

    public class MakeMap : ClassMap<Make>
    {
        public MakeMap()
        {
            Id(x => x.Id);
            Map(x => x.Name);
            HasMany(x => x.Models)
                .KeyColumn("MakeId");
            Table("Make");
        }
    }

    public class ModelMap : ClassMap<Model>
    {
        public ModelMap()
        {
            Id(x => x.Id);
            Map(x => x.Name);
            References(x => x.Make)
                .Column("MakeId");
            Table("Model");
        }
    }
}